﻿using System.Data;
using System;

namespace ShieldNet.DB
{
    /// <summary>
    /// 
    /// </summary>
    public class StoredProcedures : StoredProcedures_Base
    {

        private MainDB _db;

        public StoredProcedures(MainDB db)
            : base(db)
        {
            _db = db;
        }
        

        /// <summary>
        /// Insert thong tin cua ung dung
        /// </summary>
        /// <param name="AppKey">Key tu sinh cua ung dung</param>
        /// <param name="AppName">Ten ung dung</param>
        /// <param name="AppVersion">Phien ban cua ung dung</param>
        /// <param name="AppBundleIdentifier">Bundle Identifier</param>
        /// <param name="AppDeviceFamily">Device Family</param>
        /// <param name="AppMinimumOSVersion">Minimum OS Version</param>
        /// <param name="AppSize">Size</param>
        /// <param name="AppPlistPath">Duong dan file plist</param>
        /// <param name="AppUrlInstall">Duong dan file ipa de install</param>
        public void VNA_Insert_AppPlist(string AppKey, string AppName, string AppVersion, string AppBundleIdentifier, string AppDeviceFamily, string AppMinimumOSVersion, int AppSize, string AppPlistPath, string AppUrlInstall)
        {
            IDbCommand cmd = _db.CreateCommand("VNA_Insert_AppPlist", true);
            _db.AddParameter(cmd, "AppKey", DbType.String, AppKey);
            _db.AddParameter(cmd, "AppName", DbType.String, AppName);
            _db.AddParameter(cmd, "AppVersion", DbType.String, AppVersion);
            _db.AddParameter(cmd, "AppBundleIdentifier", DbType.String, AppBundleIdentifier);
            _db.AddParameter(cmd, "AppDeviceFamily", DbType.String, AppDeviceFamily);
            _db.AddParameter(cmd, "AppMinimumOSVersion", DbType.String, AppMinimumOSVersion);
            _db.AddParameter(cmd, "AppSize", DbType.Int32, AppSize);
            _db.AddParameter(cmd, "AppPlistPath", DbType.String, AppPlistPath);
            _db.AddParameter(cmd, "AppUrlInstall", DbType.String, AppUrlInstall);

            CreateDataTable(cmd);
           
        }


        public DataSet Select_SpamsInfo_InDay(int id, int top)
        {
            IDbCommand cmd = _db.CreateCommand("Select_SpamsInfo_InDay", true);
            _db.AddParameter(cmd, "Top", DbType.Int32, top);
            _db.AddParameter(cmd, "ID", DbType.Int32, id);
            DataSet ds = CreateDataSet(cmd);

            return ds;
        }

        public DataTable Select_SpamsInfo_PreDay(int top)
        {
            IDbCommand cmd = _db.CreateCommand("Select_SpamsInfo_PreDay", true);
            _db.AddParameter(cmd, "Top", DbType.Int32, top);
            DataTable ds = CreateDataTable(cmd);

            return ds;
        }

        /// <summary>
        /// Phan trang
        /// </summary>
        /// <param name="OffsetRows">Defalut = 1</param>
        /// <param name="FetchRows">Default = 20</param>
        /// <returns></returns>
        public DataTable Select_Spams_Paging(int OffsetRows, int FetchRows)
        {
            IDbCommand cmd = _db.CreateCommand("Select_Spams_Paging", true);
            _db.AddParameter(cmd, "OffsetRows", DbType.Int32, OffsetRows);
            _db.AddParameter(cmd, "FetchRows", DbType.Int32, FetchRows);
            DataTable dt = CreateDataTable(cmd);

            return dt;
        }

       
    }
} // End of namespace



